<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : The Server Service Application</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : The Server Service Application
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Jan 29, 2007 by <font color="#0050B2">orogers</font>.
				    </div>

				    <h3><a name="TheServerServiceApplication-InstallingCCService"></a>Installing CCService</h3>

<p>CCService is a Windows Service that can be used to launch the CCNet server.  </p>

<p>If you used the CruiseControl.NET Installer to setup CCNet on your machine, the CCNet service should already be configured. Look in the Services section of the Control Panel on your machine. Otherwise, use these instructions to setup the service manually:</p>

<ol>
	<li>Before starting to use CCService, make sure that everything is set up and configured correctly using the <a href="The Server Console Application.html" title="The Server Console Application">console executable <b>ccnet.exe</b> </a>.  It is considerably easier to debug configuration issues using the console version of CCNet than it is using CCService.  The console version of CCNet writes its output directly to the console window, so it is much easier to see what the server is doing.  CCService, by default, uses the Event Log and the ccnet.log instead.</li>
	<li>Once you have ascertained that the CCNet server is working, you need to start by configuring CCService.  If you open the <b>ccnet.service.exe.config</b> file,  you need to change the value of the <b>ccnet.config</b> setting to point to the location of your ccnet.config file.</li>
	<li>Now you are ready to install the service.  Installing a Windows Service under .NET requires using <b>installutil</b>. Open up a command prompt, change to the CruiseControl.NET server directory, and run <tt>installutil ccservice.exe</tt>. If installutil is not in your path, you should be able to locate it in something like <tt>&#37;SYSTEMROOT&#37;\Microsoft.NET\Framework\v1.1.4322</tt>.</li>
	<li>At the username/password prompt, login using a valid user account. By default, the dialog tries to login as a local user account.  If you are logging in as a domain user, the domain will have to be specified. (ie: myacct@mycompany.com, pw: mypassword, and confirm)</li>
	<li>Note: Your user account may need to be granted the "Right to Login as a Service".  This may be accomplished in two ways. The easiest method is to select a service that currently uses "Local System Account", and using a specific user account instead.  If necessary, the permissions will be granted automatically. Another method is through the Administrative Tools -&gt; Local Security Policy -&gt; Local Policies -&gt; User Rights Assignment -&gt; Log on as a Service.</li>
	<li>Whatever user that you select needs to have the necessary permissions to access all resources required by CCNet (including network shares).  The LocalSystem user may not have sufficient access.</li>
	<li>Check the EventLog to verify that CCNet output is written there.  You may want to change the CruiseControlSwitch level to reduce the verbosity of the messages to prevent the EventLog from filling.</li>
</ol>


<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Local system accounts, C++ and the dreaded 'Program Database Manager Mismatch' Error</b><br />
<p>A number of people have reported problems building C++ VS2005 projects using ccservice.  The error is C1902, "Program Database Manager Mismatch."  A tentative analysis is that Visual C++ uses a separate tool to create and update the .pdb files, and this error occurs when the version of the tool used from interactive builds in Visual Studio is different from the version used when building under ccservice.  This happens because of differences in the environment.</p>

<p>The easiest known fix is to avoid running ccservice as the SYSTEM user.  Instead, run it as the same user who owns the solution's directory tree or who builds interactively in that tree.  This will make the environments identical.</p></td></tr></table></div>

<h3><a name="TheServerServiceApplication-DebuggingCCService"></a>Debugging CCService</h3>

<ol>
	<li>Does CCService show up in the Services Management Console window? (in <b>Adminstrative Tools</b> under the <b>Start</b> menu)</li>
	<li>Does the service show as "Started" in the Services Management Console window?   Is it set to start up automatically when you restart the machine?</li>
	<li>If there is a problem starting the service, (or possibly installing it if you are doing a manual installation) is the ccservice.exe.config file valid? (You may want to use an external validator, just to make sure - Several users have reported in the mailing lists that the file looked correct, but was not valid XML.)</li>
	<li>Are there any new messages in the <b>ccnet.log file</b> or in the Event Log?</li>
	<li>Does the CCService user have sufficient priviledges to access all resources required by the CCNet server.  For example, if your source control system is stored on another server, does the user have permissions to access this server? (odds are that the LocalSystem user won't)</li>
	<li>If you are using <a href="Visual Source Safe Source Control Block.html" title="Visual Source Safe Source Control Block">Visual SourceSafe</a>, does the user account have the SSDIR environment variable defined?  If not, you should explicitly set the SsDir element in your <b>ccnet.config</b> file.</li>
	<li>Does the user account have registry access?  Can it access the email system (if you are sending the build results by <a href="Email Publisher.html" title="Email Publisher">email</a>?  Can it run Visual Studio.NET if you are using the <a href="Visual Studio Task.html" title="Visual Studio Task">Visual Studio Task</a>?</li>
	<li>Does your build user graphical elements of the .NET Framework? If so, you'll need to configure your service to have appropriate resources.</li>
	<li>Are any environment variables required by the build process accessible to the CCService user?  If they are user level environment variables then you will need to ensure that they have been set up for the CCService user.</li>
	<li>If CCTray does not connect to the server, it may be that the CCService user does not have sufficient permissions to accept incoming tcp/http connections. Check and see if there is some form of firewall software on the machine (for example Windows Firewall or ZoneAlarm). If there is, you will need to add the CCService.exe application and/or port information to your firewall settings, in order for the machine to accept incoming CCTray communications.</li>
</ol>


<h3><a name="TheServerServiceApplication-RunningmultipleinstancesofCCService"></a>Running multiple instances of CCService</h3>

<p>You can change the service name so that you can run multiple instances of CCService on the same machine.  </p>
<ol>
	<li>First, you need to create a copy of the <b>server</b> folder.  Copy the folder contents to a new location.</li>
	<li>Second, navigate to the new folder and open the <b>ccservice.exe.config</b> file in a text editor.  Edit the <b>service.name</b> element in the <b>appSettings</b> section.  The default name is <b>CCService</b>, so you should change it to something different.</li>
	<li>You should also change the remoting configuration section for the new service instance.  Specifically you should change the port for the new instance. If you don't change this then the new service will try and use the same port as the existing service.</li>
	<li>Finally, you need to install a second instance of the ccservice.  When you run <b>installutil</b> include the option switch "/ServiceName=MyCCService" (replace MyCCService with the name of the service that you specified in the <b>ccservice.exe.config</b> above).  For example, to install a second instance of CCService with the name CCService2, go to the directory containing the copied service use the following command:</li>
</ol>


<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">%SystemRoot%\Microsoft.NET\Framework\v1.1.4322\installutil.exe /ServiceName=<span class="code-quote">"CCService2"</span> ccservice.exe</pre>
</div></div>

<h3><a name="TheServerServiceApplication-UninstallingCCService"></a>Uninstalling CCService</h3>

<p>You can uninstall CCService by using the Add/Remove Programs uninstaller (if you installed CCNet via the MSI installer); however this will completely uninstall CCNet.  To only uninstall CCService, open a new VisualStudio.NET command prompt and run <tt>installutil ccservice.exe /u</tt> in the directory containing the CCNet server.  If you have multiple instances of CCService installed, you can use the "/ServiceName" switch to specify which instance to uninstall.</p>


<h3><a name="TheServerServiceApplication-RunningCCServiceastheLocalSystemaccount"></a>Running CCService as the LocalSystem account</h3>

<p>By default, when the CCService is installed, it will be set up to run under the LocalSystem account.  While the LocalSystem account has extensive privileges for the local machine, it is not able to directly authenticate and access resources across the network.  If this is a necessary part of your build process then you should try running CCService using a Domain Account instead.</p>

<p>If you are set on using the LocalSystem account and are finding problems running CCNet, one way to diagnose problems is to open a command prompt as the LocalSystem account and then trying to run the CCNet console application (<b>ccnet.exe</b>) directly from the command prompt to see what the problem is.  This <a href="http://blogs.msdn.com/adioltean/articles/271063.aspx">blog post</a> describes some different approaches to opening a command prompt window running as the LocalSystem user. </p>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>